#ifndef _irda_c
#define _irda_c

// Generate a 153600 Hz signal
// Count to 52 pulses at 16MHz, toggle clock pin
// Note - inhibited for 2 clock cycles when value is updated

#define TMR0_PRELOAD_LO    207
#define TMR0_PRELOAD_HI    207

void irda_config( void )
{
   TMR0L = TMR0_PRELOAD_LO;
   T0CON = 0b11001000;
   TMR0IP = 0;    // low priority
}

void isr_irda( void )
{
   if( CLK_PIN )
   {
      TMR0L += TMR0_PRELOAD_LO; 
      CLK_PIN = 0;
   }
   else
   {  
      TMR0L += TMR0_PRELOAD_HI; 
      CLK_PIN = 1;
   }
   TMR0IF = 0;
}

#endif

